<!-- 新版 排行榜 -->
<template>
  <div id="ranking_xpc">
    <c-title :hide="false" :text="'排行榜'"></c-title>
    <template v-if="!fun.isTextEmpty(titleArr)">
      <van-tabs animated swipeable sticky :ellipsis="false" class="tabs_style" line-width="1.1563rem"
        v-model="activeName" @change="handleClick(false)" title-active-color="var(--themeBaseColor)"
        color="var(--themeBaseColor)">
        <van-tab v-for="(item, index) in titleArr" :title="item" :key="index">
          <van-tabs type="card" v-model="active" class="zs_tabs" v-show="dataList[index].plugin_type == 'Merchants'"
            @click="handleClick(true)">
            <!-- 招商的标签页  招商员和招商中心 -->
            <van-tab :title="itemss.name" :name="itemss.type" v-for="(itemss, ind) in merchanrTitle"
              :key="ind"></van-tab>
          </van-tabs>
          <div class="linear-gradient">

            <div
              :class="dataList[index].info && dataList[index].info.status && dataList[index].info.status == 1 ? 'topBox' : 'topBox-1'">
              <template
                v-if="dataList[index].info && (dataList[index].info.usable_total || dataList[index].info.usable_total == 0)">
                <!-- 有开通显示 -->
                <div style="position: relative;">
                  <div class="memberInfo">
                    <img :src="dataList[index].member_amount ? dataList[index].member_amount.avatar_image : ''"
                      alt="" />
                    <div class="tx">
                      <div class="name">
                        {{ dataList[index].member_amount ? dataList[index].member_amount.nickname : '' }}
                      </div>
                      <div class="Rank">
                        <img :src="customer_image_url + '/ranking/ranking.png'" />
                        <p>NO.{{ dataList[index].info.countNO }}</p>
                      </div>
                    </div>
                  </div>
                  <img class="trophy" :src="customer_image_url + '/ranking/trophy.png'" alt="" />
                </div>
                <div class="moneyTotal">
                  <div class="child">
                    <div class="num">{{ dataList[index].info.grand_total }}</div>
                    <div class="num_name">累计收益(元)</div>
                  </div>
                  <div class="child">
                    <div class="num">{{ dataList[index].info.usable_total }}</div>
                    <div class="num_name">可提现(元)</div>
                  </div>
                  <router-link :to="fun.getUrl('withdrawal', {})" class="child withdraw" tag="div">提现</router-link>
                </div>
              </template>
              <div v-if="dataList[index].info && dataList[index].info.status && dataList[index].info.status == 1"
                class="no-apply-for">
                <!-- 没有开通，显示去申请 getSwitch有返回status字段-->
                <p class="applyTest">{{ dataList[index].variable }}</p>
                <div class="applyBtn" v-show="dataList[index].plugin_type != 'teamDividend'"
                  @click="gotoApply(dataList[index].plugin_type)">
                  去申请
                </div>
              </div>
            </div>
            <!-- 店长中心 微店且满足条件时才显示 -->
            <div class="storeCenter"
              v-if="dataList[index].plugin_type == 'micro' && !dataList[index].info.hasOwnProperty('status')">
              <div class="checkStoreDetails-left">
                <img :src="customer_image_url + '/ranking/store_manager.png'" style="width: 2rem;" />
                <span>店长中心</span>
              </div>
              <div @click="gotoStore" class="sc_btn">
                <span>进入</span>
                <i class="iconfont icon-icon_more11"></i>
              </div>
            </div>

            <!-- 查看详情 -->
            <div class="lookDetail"
              v-if="dataList[index].plugin_type != 'micro' && !dataList[index].info.hasOwnProperty('status') && (dataList[index].plugin_type != 'income' || showDetail)"
              @click="gotoDetail(dataList[index].plugin_type)">
              <div class="detail_box" v-if="dataList[index].plugin_type != 'income'" :style="!showDetail?'margin-bottom:0':''">
                <div class="detail_box_tips">数据详情</div>
                <div class="detail_box_right">
                  <p>查看更多</p>
                  <i class="fa fa-angle-right"></i>
                </div>
              </div>
              <div class="card_box" v-if="showDetail">
                <div class="check_btn_bg">
                  <div class="card_style">
                    <div class="num">{{ dataList[index].info.countNum }}</div>
                    <div class="card_name">{{ countNum_name }}</div>
                  </div>
                  <img class="card_img" :src="customer_image_url + '/ranking/client.png'" alt="" />
                </div>

                <div class="check_btn_bg">
                  <div class="card_style">
                    <div class="num" v-if="dataList[index].info.countOrder">{{
                      Number(dataList[index].info.countOrder).toFixed(2) }}
                    </div>
                    <div class="card_name">{{ countOrder_name }}</div>
                  </div>
                  <img class="card_img" :src="customer_image_url + '/ranking/order.png'" alt="" />
                </div>
              </div>
            </div>

            <div class="income_rank">
              <p class="income_title">
                <span>收益排行榜</span>
                <span class="month-style" @click="showTime = true"
                  v-if="dataList[activeName].plugin_type == 'income'">{{
                    currentShowTime.split('-')[0] + '年' +
                    currentShowTime.split('-')[1] + '月' }} <van-icon name="arrow-down" /> </span>
              </p>
              <div class="income_nav">
                <div class="income_nav_left">
                  <div class="income_randNum">排名</div>
                  <div class="member">{{ member_name }}</div>
                </div>
                <div class="total">累计收益</div>
              </div>
              <ul class="income_list">
                <template v-if="!fun.isTextEmpty(dataList) && !fun.isTextEmpty(dataList[index].list)">
                  <li class="list_child" v-for="(item, i) in dataList[index].list" :key="i"
                    :class="[i == 0 ? 'list_child_no1' : i == 1 ? 'list_child_no2' : i == 2 ? 'list_child_no3' : '']">
                    <div class="list_child_left">
                      <div class="income_randNum">{{ is_show_income_ranking == 1 ? countNO : i + 1 }}</div>
                      <div class="member">
                        <img v-if="item.avatar" :src="item.avatar
                          ? item.avatar
                          : require('../../../assets/images/loading.jpg')
                          " alt="" />
                        <p >{{item.nickname}}</p>
                      </div>
                    </div>

                    <div class="total">{{ item.total_amount }}</div>
                  </li>
                </template>
                <img src="../../../assets/images/blank.png" alt="" style="width: 5rem; margin-top: 2rem;"
                  v-if="fun.isTextEmpty(dataList[index].list)" />
              </ul>
            </div>

          </div>
        </van-tab>
      </van-tabs>
    </template>
    <div class="bottom_box set-pc-style">
      <div class="pc-style"></div>
      <router-link class="home" :to="fun.getUrl('home', {})" tag="div">
        <i class="iconfont icon-home-page"></i>
        <em>首页</em>
      </router-link>
      <div class="btn_box">
        <div class="warn" @click="showPopup1 = true" v-show="poster_text_sy">{{ poster_text_sy }}</div>
        <div class="share" @click="getPoster">分享</div>
      </div>
    </div>

    <!-- 收益提醒弹窗 -->
    <van-popup v-model="showPopup1" closeable round>
      <div class="sy_popup">
        <img :src="poster_thumb_sy" alt="" />
        <p class="sy_text">{{ poster_text_sy }}</p>
      </div>
    </van-popup>

    <!-- 分享海报 -->
    <van-popup v-model="showPoster" closeable round>
      <div class="style_popup">
        <img :src="`${image_url}?${Date.now()}`" alt="" v-if="!fun.isTextEmpty(image_url)" />
      </div>
    </van-popup>

    <!-- 选择月份搜索 -->
    <van-popup v-model="showTime" round position="bottom" :style="{ height: '40%' }">
      <van-datetime-picker v-model="currentDate" type="year-month" title="选择月份" :formatter="formatter"
        @confirm="confirmTime" @cancel="showTime = false" :min-date="minDate" :max-date="maxDate" />
    </van-popup>
  </div>
</template>

<script>
import rankings_controller from './ranking_controller.js';
export default rankings_controller;
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
#appMain.pcStyle .van-popup {
  margin-right: 0 !important;
  transform: translate(50%,-50%);
  width: unset !important;
}
::v-deep .van-tab__pane-wrapper {
  display: flex !important;
}

.check_btn_bg {
  width: 9.8125rem;
  height: 5.3125rem;
  border-radius: 0.75rem;
  background: linear-gradient(181deg, #FFF4DB 0%, rgba(250, 240, 218, 0.15) 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-right: 1.2188rem;
  box-sizing: border-box;
}

#ranking_xpc {
  padding: 0 0 75px;
  position: relative;

  &::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background-color: #fff;
    height: 15.625rem;
    z-index: -1;
  }

  .trophy {
    position: absolute;
    right: -0.25rem;
    bottom: -3.5rem;
    width: 9.5625rem !important;
    height: auto !important;
  }

  .zs_tabs {
    background: #F6F6F6;
    margin: 0.5rem 0.75rem .625rem;
    height: 2.5rem;
    line-height: 2.5rem;
    border-radius: 1.875rem;
    padding: 0.125rem;
    overflow: hidden;

    ::v-deep .van-tabs__wrap {
      height: 100%;
    }

    ::v-deep .van-tabs__nav--card {
      height: 100%;
      // width: 9.375rem;
      margin: 0 auto;
      border: none;
      border-radius: 1rem;
      overflow: hidden;
      background: #fff !important;
    }

    ::v-deep .van-tab {
      background-color: #F6F6F6;
      color: #6E6E79;
      font-size: 0.8125rem;
      border: none;
    }

    ::v-deep .van-tab--active {
      color: #00001C;
      font-size: 0.9375rem;
      border: none;
      background-color: #FFFFFF;
    }
  }

  .header {
    height: 40px;
    line-height: 40px;
    position: fixed;
    display: flex;
    top: 0;
    left: 0;
    background: #fffafa;
    width: 100%;
    color: #000;

    i {
      font-size: 1rem;
      width: 2rem;
    }

    .text {
      flex: 1;
      text-align: center;
      margin-left: -2rem;
      font-size: 0.9375rem;
      font-weight: bold;
    }
  }

  .tabs_style {

    ::v-deep .van-tabs__line {
      background-color: #333;
    }

    ::v-deep .van-tabs__wrap::after {
      border: none;
    }
  }

  .linear-gradient {
    position: relative;
    padding-top: 1.25rem;
    margin-top: .3438rem;
  }

  .linear-gradient::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 22.4688rem;
    background: linear-gradient(196deg, #F8E9C5 0%, rgba(255, 255, 255, 0) 100%);
    border-radius: 1.9063rem 1.9063rem 0 0;
  }

  .no-apply-for {
    padding: 0.9375rem 0.9063rem;
    display: flex;
    align-items: center;
    justify-content: space-between;

  }

  .topBox-1 {
    position: relative;
    z-index: 10;
    margin: 0 .625rem .625rem;

    .Rank {
      position: relative;
      text-align: right;
      width: max-content;
      padding-left: 0.75rem;
      margin-left: 1.25rem;
      height: 1.1875rem;
      background: linear-gradient(270deg, #FDEEC6 0%, #FEC768 100%);
      border-radius: 0.6563rem;
    }

    .Rank p {
      font-weight: bold;
      font-size: 0.8125rem;
      color: #8B380A;
      padding-right: .4063rem;
    }

    .Rank img {
      position: absolute;
      width: 1.5rem;
      height: 1.6875rem;
      margin: 0;
      left: 0;
      top: 0;
      transform: translate(-63%, -15%);
    }

    .memberInfo {
      display: flex;
      align-items: center;
      padding-left: 0.5938rem;
    }

    .name {
      color: #8B380A;
      font-weight: bold;
      text-align: left;
      font-size: 1.125rem;
      line-height: 1;
      margin-left: .6563rem;
      margin-bottom: .5625rem;
    }

    img {
      width: 3.5rem;
      height: 3.5rem;
      border-radius: 100%;
      margin: 0;
    }

    .moneyTotal {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 1.0938rem;
      background-color: #fff;
      border-radius: .5rem;
      height: 4.6875rem;
      padding: 0 .75rem;
      box-sizing: border-box;

    }

    .child {
      display: flex;
      flex-direction: column;
      color: #333;


    }

    .num {
      font-size: 1rem;
      font-weight: bold;
      text-align: left;
      color: #00001C;
    }

    .num_name {
      color: #6E6E79;
      font-size: 0.75rem;
    }

    .withdraw {
      width: 4rem;
      height: 2.25rem;
      line-height: 2.25rem;
      background: var(--themeBaseColor);
      color: #fff;
      font-weight: 500;
      font-size: 0.8125rem;
      border-radius: 1.0938rem;
    }
  }

  .topBox {
    position: relative;
    z-index: 10;
    margin: 0 .625rem .625rem;
    border-radius: .5rem;
    background-color: #fff;


    .applyTest {
      font-weight: bold;
      font-size: 1rem;
      color: #00001C;
    }

    .applyBtn {
      width: 4.75rem;
      height: 2.25rem;
      line-height: 2.25rem;
      background: var(--themeBaseColor);
      border-radius: 1.0938rem;
      font-size: .8125rem;
      color: #fff;
      font-weight: 500;
      text-align: center;
    }

    .memberInfo {
      display: flex;
      align-items: center;
      margin-bottom: 1.5rem;

      .tx {
        width: 4.25rem;
        height: 4.25rem;
        position: relative;

        img {
          width: 100%;
          height: 100%;
          border-radius: 100%;
        }

        .Rank {
          position: absolute;
          bottom: -0.5rem;
          display: block;
          left: 50%;
          -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);

          i {
            color: #ffb43e;
            font-size: 1rem;
            position: absolute;
            top: -0.5rem;
            left: -0.5rem;
          }

          p {
            display: block;
            font-size: 0.75rem;
            height: 1rem;
            line-height: 1rem;
            background: #ffb43e;
            color: #fff;
            padding: 0 0.5rem;
            border-radius: 1rem;
            min-width: 4rem;
          }
        }
      }

      .name {
        flex: 1;
        font-size: 1.125rem;
        color: #333;
        margin-left: 0.75rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
      }
    }


  }

  .storeCenter {
    position: relative;
    height: 3.75rem;
    border-radius: 0.5rem;
    border: 1px solid #FFFFFF;
    background-color: #fff;
    padding: 0 0.75rem;
    display: flex;
    align-items: center;
    z-index: 99;
    position: relative;
    justify-content: space-between;
    margin: .625rem .75rem;
    &::after{
      position: absolute;
      content:"";
      left: 0;
      top: 0;
      bottom: 0;
      right: 20%;
      z-index: -1;
      background: linear-gradient(170deg, #FDE9BB 0%, #FFFFFF 50%);
      border-radius: 0.5rem;
      
    }

    .checkStoreDetails-left {
      display: flex;
      align-items: center;
    }

    .checkStoreDetails-left span {
      font-weight: 500;
      font-size: 1rem;
      margin-left: 0.4063rem;
      color: #00001C;
    }

    .icon-icon_more11 {
      margin-left: 0.3125rem;
      font-size: 0.7188rem;
      color: #AAAAB3;
    }


    .sc_btn {
      font-weight: 400;
      line-height: 1;
      display: flex;
      align-items: center;
      font-size: 0.8125rem;
      color: #AAAAB3;
      z-index: 99;
    }
  }

  .detail_box_tips {
    font-weight: bold;
    font-size: 1rem;
    color: #00001C;
  }

  .detail_box_right {
    display: flex;
    align-items: center;
    color: #AAAAB3;
    font-size: .8125rem;
    font-weight: 400;
    line-height: 1;
  }
  .fa-angle-right {
      margin-left: 0.3125rem;
      font-size: 0.9375rem !important;
      color: #AAAAB3;
  }

  .lookDetail {
    position: relative;
    z-index: 10;
    margin: .625rem .75rem .75rem;
    background: #FFFFFF;
    border-radius: 0.5rem;
    padding: .9688rem .75rem .9375rem;
    box-sizing: border-box;

    .detail_box {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: .9375rem;
      line-height: 1;

      i {
        font-size: 1.25rem;
      }
    }

    .card_box {
      display: flex;
      align-items: center;
      justify-content: space-between;

      .card_img {
        width: 2rem;
        margin: 0;
        flex-shrink: 0;
      }

      .card_style {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        flex: 1;
        justify-content: center;

        .card_name {
          overflow: hidden;
          text-overflow: ellipsis;
          // white-space: nowrap;
          // max-width: 50%;
          text-align: left;
          font-weight: 400;
          font-size: 0.75rem;
          color: #6E6E79;
          margin-left: .9063rem;
        }
      }


      .num {
        font-weight: bold;
        font-size: 1.125rem;
        line-height: 1;
        margin-bottom: 0.5rem;
        margin-left: 1.0313rem;
        color: #00001C;
      }
    }
  }

  .income_rank {
    position: relative;
    z-index: 10;
    margin: .625rem .75rem;
    background-color: #fff;
    border-radius: 0.5rem;
    padding: 1.2188rem .625rem .9375rem .7813rem;

    .income_title {
      font-size: 1rem;
      color: #00001C;
      font-weight: bold;
      text-align: left;
      margin-bottom: 1.4688rem;
      line-height: 1;
      display: flex;
      justify-content: space-between;

      .month-style {
        font-size: 0.8rem;
        color: #e93b38;
      }
    }

    .income_nav_left,
    .list_child_left {
      display: flex;
      align-items: center;
    }

    .income_nav {
      margin-bottom: 1.125rem;
      line-height: 1;
    }


    .income_nav,
    .list_child {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-weight: 400;
      font-size: 0.8125rem;
      color: #6E6E79;
      padding-left: .375rem;
      padding-right: .9063rem;
      box-sizing: border-box;

      .income_randNum {
        margin-right: 1.5625rem;
      }
    }

    // .list_child {

    //   .total {
    //     flex: 1;
    //     max-width: 10rem;
    //     line-height: 1rem;
    //     word-break: break-all;
    //     display: flex;
    //     justify-content: center;
    //     align-items: center;
    //   }
    //}
    .list_child_no1 {
      background: linear-gradient(90deg, #FCF4E4 0%, #FFFFFF 100%);
      border-radius: 0.75rem;

      .income_randNum {
        color: #FBBE3D;
        font-size: 1rem;
        font-weight: 800;
      }

      img {
        width: 2.0625rem !important;
        height: 2.0625rem !important;
        border: 0.0938rem solid #FFDA90;
      }
    }

    .list_child_no2 {
      background: linear-gradient(90deg, #EBF2FC 0%, #FFFFFF 100%);
      border-radius: 0.75rem;

      .income_randNum {
        color: #A7B6CF;
        font-size: 1rem;
        font-weight: 800;
      }

      img {
        width: 2.0625rem !important;
        height: 2.0625rem !important;
        border: 0.0938rem solid #C4D7F0;
      }
    }

    .list_child_no3 {
      background: linear-gradient(90deg, #FFEBE5 0%, #FFFFFF 100%);
      border-radius: 0.75rem;

      .income_randNum {
        color: #E36C42;
        font-size: 1rem;
        font-weight: 800;
      }

      img {

        width: 2.0625rem !important;
        height: 2.0625rem !important;
        border: 0.0938rem solid #F5BAA3;
      }
    }

    .list_child {
      height: 3.4375rem;
      margin-bottom: .375rem;
      padding-left: 1.0313rem !important;

      .income_randNum {
        font-size: 1rem;
        font-weight: 800;
        margin-right: 1.875rem !important;
      }

      .total {
        font-weight: 500;
        font-size: 0.8125rem;
        color: #00001C;
      }

      .member {
        flex: 1;
        display: flex;
        align-items: center;
        overflow: hidden;

        img {
          width: 2rem;
          height: 2rem;
          border-radius: 100%;
          overflow: hidden;
          margin: 0;
          margin-right: .625rem;
          object-fit: cover;
        }

        p {
          font-size: .8125rem;
          font-weight: 500;
          color: #00001C;
          flex: 1;
          max-width: 9rem;
          text-align: left;
          overflow: hidden;
          /* 超出部分隐藏 */
          text-overflow: ellipsis;
          /* 超出部分显示省略号 */
          white-space: nowrap;
          /* 规定段落中的文本不进行换行 */
        }
      }
    }
  }
  .pc-style{   
   
    position: absolute;
     box-shadow: 0 9.3rem 1rem 9rem rgba(0,0,0,0.1);
    left: 0;
    right: 0;
    height: 3.75rem;
    background: #fff;
    z-index: -1;
  }

  .bottom_box {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3.5rem;
    padding: 0 .75rem 0 1.5625rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    overflow-x:clip;
    // box-shadow:  0 9.3rem 1rem 9rem rgba(0, 0, 0, 0.1);
    

    .home {
      display: flex;
      flex-direction: column;

      i {
        color: #666;
        font-size: 1.5rem;
      }

      em {
        color: #666;
        font-size: 0.75rem;
      }
    }

    .btn_box {
      display: flex;

      .warn,
      .share {
        width: 8.75rem;
        height: 2.5rem;
        line-height: 2.5rem;
        border-radius: 1.2188rem;
        border: 1px solid var(--themeBaseColor);
        color: var(--themeBaseColor);
        font-size: .875rem;
        text-align: center;
      }

      .share {
        color: #FFFFFF !important;
        background: var(--themeBaseColor);
        text-align: center;
        margin-left: .75rem;
      }

      .warn {
        padding: 0 0.875rem;
        overflow: hidden;
        /* 超出部分隐藏 */
        text-overflow: ellipsis;
        /* 超出部分显示省略号 */
        white-space: nowrap;
        /* 规定段落中的文本不进行换行 */
      }
    }
  }

  .sy_popup {
    padding: 2.5rem;

    img {
      width: 14rem;
      height: 14rem;
      overflow: hidden;
    }

    .sy_text {
      font-size: 0.875rem;
      color: #666;
      margin-top: 0.25rem;
    }
  }

  .style_popup {
    width: 17rem;
    font-size: 0;

    img {
      width: 100%;
    }
  }
}
</style>
